<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Employeecate extends CI_Controller {
	public function __construct(){
								parent::__construct();
								//$this->load->model(array("departmodel"));
				}

					public function index()
					{

				        $data=array();
						load($this->db,$this->session,$this->load,"employeecate","home",$data);
					}



            public function get_category(){
            	     $arr=read_category($this->db,'-1');
            	      $str=json_encode($arr);

            	      echo $str;
            }

             

           public function save_category(){
           // $arr=$this->input->post();
           	$parent=$this->input->post("parent");
           	$name=$this->input->post("name");
           	
           	$arr=array("parent"=>$parent,"name"=>$name);
           	if($this->db->insert("empcate",$arr)){
		           	ajaxsuccess();
		           }else{
		           	ajaxfail();
		           }

           }


           public function save_edit_category(){
           	$id=$this->input->post("id");
           	$name=$this->input->post("name");
          
           	$sql="update empcate set name='$name' where id='$id'";
           	if($this->db->query($sql)){
		           	ajaxsuccess();
		           }else{
		           	ajaxfail();
		           }

           }


           public function del_category(){
           	$id=$this->input->post("id");

           	$sql="delete from empcate where id='$id'";

           	if($this->db->query($sql)){
           		ajaxsuccess();
           	}else{
           		ajaxfail();
           	}
           }


           


}
